from allpairspy import AllPairs

from api_py.enums.cookie import Cookie
from api_py.generate_case.template import template_case
from api_py.utils.file_sys import write_json

# TODO 如果该督导本身信息不合法，将这一不合法的督导通过本接口删除，那么这个算缺陷吗

username = [
    {"value": "", "description": "用户名为空串"},
    {"value": "(counselor)", "description": "非法用户名"},
    {"value": "deleteCounselor", "description": "合法用户名"}
]

cookies = [
    {"value": Cookie.ADMIN_COOKIE.value, "description": "管理员登录"},
    {"value": Cookie.SUPERVISOR_COOKIE.value, "description": "督导登录"},
    {"value": Cookie.COUNSELOR_COOKIE.value, "description": "咨询师登录"},
    {"value": Cookie.WEIXIN_COOKIE.value, "description": "微信访客登录"},
    {"value": Cookie.NULL_COOKIE.value, "description": "未登录"},
    {"value": Cookie.ERROR_COOKIE.value, "description": "其他Cookie"},
]


def case14_user_ms_counselor(api_type):
    json_result = {}
    i = 0

    # 检测数据格式的用例
    for un in username:
        case = template_case()
        request = case["request"]

        # 包装url参数
        request["params"]["username"] = un
        # 包装头部信息
        request["headers"]["Cookie"] = cookies[0]

        json_result[i] = case
        i += 1

    # 检查用户权限的用例
    for cookie in cookies:
        case = template_case()
        request = case["request"]

        # 包装url参数
        request["params"]["username"] = username[2]
        # 包装头部信息
        request["headers"]["Cookie"] = cookie

        json_result[i] = case
        i += 1

    write_json(api_type.value[0]["file_name"], json_result)
